<?php
/**
 * ============================================================================
 * Doxt Version: 1.0           杭州多讯科技有限公司
 * Web: http://www.doxt.com
 * Copyright (C) 2007 - 2010 Doxt Technology Inc., All Rights Reserved.
 * ---------------------------------------------
 * $Date: 2008.4.8
*/

function subfl(&$muster, $fid)
{
  global $con, $conf;
  $sql = "SELECT cate_id,zh_cate_title FROM " . $conf["tbl_prefix"] . "news_cate WHERE parent_id='$fid' ORDER BY cate_id DESC";
  $result1 = mysql_query($sql) or die(mysql_error());
  if ($myrow1 = mysql_fetch_array($result1))
  {
    $muster .= "cate[$fid] = new Array(); \n";   //声明两维数组
    $i = -1;  //用于产生数组的下标值
    do {
	 $i ++;
	 $cate_id = $myrow1["cate_id"];
 	 $c_name = $myrow1["zh_cate_title"];
     $muster .= "cate[$fid][$i] = '" . $c_name . "|$cate_id';\n";
     subfl(&$muster, $myrow1["cate_id"]);
   } while ($myrow1=mysql_fetch_array($result1));
  } //End if
 } //End if
 $tpl -> set_file("page", "list_cate.htm");
 $tpl -> set_block("page", "LIST_CATE", "list_cate");  //大类块
 //生成javascript 数组
 $sql = "SELECT cate_id,zh_cate_title FROM $TBL_CATE WHERE parent_id=0 ORDER BY cate_id";
 $result = mysql_query($sql);
 $i = -1;
 if ($myrow = @mysql_fetch_array($result))
 {
   do
   {
     $i ++;
     $c_name = $myrow["zh_cate_title"];  
     $cate_id = $myrow["cate_id"];
     $muster .= "cate[0][$i] = '" . $c_name . "|$cate_id';\n";
     subfl($muster, $myrow["cate_id"]); //此处调用子级分类函数
     $CHECK = "";	 
     if ($cate_id == $top_cate_id)	 
	 { 
	   $CHECK = "selected=\"selected\"";
	 }
	 $tpl -> set_var(array(
	                       "CATE_VAL" => $cate_id,
						   "CATE_CNAME" => $c_name,
						   "CHECK" => $CHECK
	                 ));
     $tpl -> parse("list_cate", "LIST_CATE", true);					 
   } while ($myrow = mysql_fetch_array($result));
 }  
 $tpl -> set_var(array(
                    "MUSTER" => $muster
                  ));
 $tpl -> parse("Output", "page");
 $show_cate = $tpl -> get("Output");
?>